<?php
/**
 * CreateTime: 2022/7/18 14:35
 */

namespace App\Http\Controllers\Workbench;

use App\Consts\ResponseConsts\ResponseStatusConsts;
use App\Func\ResponseFunc;
use App\Func\TokenFuc;
use App\Http\Controllers\Controller;
use App\Http\Requests\ListBasicRequest;
use App\Models\Agenda\AgendaModel;
use App\Service\Workbench\WorkbenchService;
use App\Tools\DingTalk\DingTalkApprovalProcess;
use Illuminate\Http\Exceptions\HttpResponseException;

class WorkbenchController extends Controller
{

    public $workbenchService;

    public function __construct()
    {
        $this->workbenchService = new WorkbenchService();
    }

    public function getApprovalPendingNumber(){
        return ResponseFunc::returnJson(
            'ok',
            ['count' => 0],
            "获取当前客户审批个数成功",
            ResponseStatusConsts::OK_200_RESPONSE_STATUS
        );
        $staffId = TokenFuc::getCurrentStaffInfo();
        if(!@$staffId['dingTalkId']){
            throw new HttpResponseException( ResponseFunc::returnJson(
                'error',
                '',
                "当前客户未绑定钉钉",
                ResponseStatusConsts::INTERNAL_SERVER_ERROR_500_RESPONSE_STATUS
            ));
        }
        $dp = new DingTalkApprovalProcess();
        $count = $dp::getUserApprovalProcessCount($staffId['dingTalkId']);
        return ResponseFunc::returnJson(
            'ok',
            ['count' => $count],
            "获取当前客户审批个数成功",
            ResponseStatusConsts::OK_200_RESPONSE_STATUS
        );
    }

    public function getSelfAgendaList(ListBasicRequest $request){
        $pFilters = $request->get('filters');
        $pageSize = $request->get('page_size');
        return ResponseFunc::returnJson(
            'ok',
            $this->workbenchService->getSelfAgendaList($pageSize,$pFilters),
            '获取我的待办成功',
            ResponseStatusConsts::OK_200_RESPONSE_STATUS
        );
    }

    public function getSelfContractCalendar(ListBasicRequest $request): \Illuminate\Http\JsonResponse
    {
        return ResponseFunc::returnJson(
            'ok',
            $this->workbenchService->getSelfContractCalendar(),
            '获取我的待办成功',
            ResponseStatusConsts::OK_200_RESPONSE_STATUS
        );
    }

}